<%@page import="org.asportoonline.entities.Locale"%>
<%@page import="java.util.List"%>
<%
    int num_locali = 0;
    int step = 1;
    String loc = "";

    List<String> nomi_categorie = null;
    int[] numero_categorie = null;
    if (request.getParameter("mode") != null && request.getParameter("mode").toString().equals("second_search")) {
        step = 2;
        num_locali = Integer.parseInt(request.getAttribute("num_locali").toString());
        loc = request.getParameter("loc").toString();
        nomi_categorie = (List<String>) request.getAttribute("nomi_categorie");

        if (nomi_categorie != null) {
            int[] temp = (int[]) request.getAttribute("numero_categorie");
            numero_categorie = new int[temp.length];

            for (int i = 0; i < temp.length; i++) {
                numero_categorie[i] = temp[i];
            }
        }
    }

%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tlds/asportoonline.tld" prefix="asportoonline" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>AsportoOnline | Home</title>
        <style type="text/css">
            @import url("style.css");
        </style>
    </head>
    <body>
        <div class="meister">
            <div class="page">
                <div class="container">
                    <%@ include file="/WEB-INF/common/header.jsp"%>
                    <div class="navigation"> <a id="first" href="MainController?q=index">Home</a></div>        

                    <% if (step == 1) {%>
                    <div class="searchArea">
                        <div id="homeTitle">
                            <h1>Ordina il tuo pranzo o la tua cena con noi!</h1>
                        </div>
                        <div id="searchAreaForm">
                            <form method="post" action="MainController?q=base_search">
                                <select name="localita">
                                    <asportoonline:elenco_localita localita="${localita}"></asportoonline:elenco_localita>
                                </select>
                                <div id="searchAreaButtonSearch">
                                    <input class="linkopacity" type="image" alt="cerca la pizzeria o il ristorante a domicilio vicino a te" src="img/cerca.png"/>
                                </div>						
                            </form>
                        </div>
                        <% } else {%>
                        <div class="searchAreaCategories">
                            <h3>Scegli la categoria</h3>
                            <asportoonline:elenco_categorie_per_la_ricerca nomi_categorie="<%=nomi_categorie%>" numero_categorie="<%=numero_categorie%>" localita="<%=loc%>" />


                            <p>Oppure</p>

                            <a id="otherSearchResults" href="MainController?q=view_restaurants_by_locality&AMP;loc=<%=loc%>">Visualizza i <%=num_locali%> locali trovati in <%=loc%></a>
                        </div>        
                        <% }%>
                    </div>

                    <p>${error}</p>
                    <%@ include file="/WEB-INF/common/footer.jsp"%>
                </div>
            </div>
        </div>
    </body>
</html>
